package com.hjm.suanfa.美团;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

public class 平衡矩阵 {
    // https://www.nowcoder.com/exam/test/88247074/detail?pid=55750560&examPageSource=Company&subTabName=written_page&testCallback=https%3A%2F%2Fwww.nowcoder.com%2Fexam%2Fcompany%3FquestionJobId%3D10%26subTabName%3Dwritten_page&testclass=%E8%BD%AF%E4%BB%B6%E5%BC%80%E5%8F%91

    // 读取数据 BufferedReader 比 scanner 要快
    // 但是不会自己处理 空格问题
//        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
//        int n = Integer.parseInt(in.readLine().trim());
//        int[][] A = new int[n + 1][n + 1];  // 1-based 填充
//
//        for (int i = 1; i <= n; i++) {
//            StringTokenizer st = new StringTokenizer(in.readLine());
//            for (int j = 1; j <= n; j++) {
//                A[i][j] = Integer.parseInt(st.nextToken());
//            }
//        }

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        in.nextLine();
        int[][] arr = new int[n + 1][n + 1];
        for (int i = 1; i <= n; i++) {
            String line = in.nextLine();
            char[] st = line.toCharArray();
            for (int j = 1; j <= n; j++) {
                // 根据 char 获取对应的 数字
                arr[i][j] = Character.getNumericValue(st[j - 1]);
//                arr[i][j] = Integer.parseInt(String.valueOf(st[j - 1]));
            }
        }
        for (int i = 1; i <= n; i++) {
            String line = in.nextLine();
            char[] st = line.toCharArray();
            for (int j = 1; j <= n; j++) {
                arr[i][j] = Integer.parseInt(String.valueOf(st[j - 1]));
            }
        }
        // 二维数组的前缀和
        int[][] sum = new int[n + 1][n + 1];
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + arr[i][j];
            }
        }

        int[] ans = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            int count = 0;
            // 如果总数为奇数，不可能出现完美矩形
            if (i * i % 2 != 0) {
                ans[i] = 0;
                continue;
            }
            // 总数为 偶数 ，那么 0和1 各一半
            int target = i * i / 2;
            // 开始遍历
            for (int x1 = 1; x1 + i - 1 <= n; x1++) {
                // 这里的x2 代表格子有多大
                int x2 = x1 + i - 1;
                for (int y1 = 1; y1 + i - 1 <= n; y1++) {
                    int y2 = y1 + i - 1;
                    // 前缀和求区间和：S[x2][y2] - S[x1-1][y2] - S[x2][y1-1] + S[x1-1][y1-1]
                    // 这里求的是 矩阵大小为 i 的总和
                    int ones = sum[x2][y2] - sum[x1 - 1][y2] - sum[x2][y1 - 1] + sum[x1 - 1][y1 -
                            1];
                    if (ones == target) {
                        count++;
                    }
                }
            }

            ans[i] = count;
        }
        // 输出 1 ≤ i ≤ n 的答案
        StringBuilder sb = new StringBuilder();
        for (int i = 1; i <= n; i++) {
            sb.append(ans[i]).append('\n');
        }
        System.out.print(sb.toString());

    }
}
